<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org" xmlns:sec="http://www.thymeleaf.org/thymeleaf-extras-springsecurity3">
<head th:replace="top::html" />
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">

<body class="fixed hold-transition skin-blue">
    <div class="wrapper">
        <div th:replace="tophtml::html"></div>
        <div th:replace="left::html"></div>

        <div class="content-wrapper">
            <section class="content-header">
                <h1>
                    <span>专家关联项目</span>
                    <small></small>
                </h1>
                <ol class="breadcrumb">
                    <li><a th:href="@{/index}"><i class="fa fa-dashboard"></i>用户中心</a></li>
                    <li><a th:href="@{/person/findPersonList}"><i class="fa fa-dashboard"></i>专家管理</a></li>
                    <li><a href="">专家关联项目</a></li>
                </ol>
            </section>
            <!-- Main content -->
            <section class="content container-fluid">
                <form id="from1" class="form-inline" th:action="@{/project/showHolderAddProject}" method="get">
                    <input type="hidden" name="pageNo" id="pageNo" />
                    <input type="hidden" name="personId" th:value="${param.personId}" />
                    <div class="form-group">
                        <input style="width: 500px; display: inline" type="text" class="form-control" placeholder="id或名称" name="searchKeyword" th:value="${searchKeyword}">
	                    <button type="submit" class="btn btn-primary" style="margin-left: 40px;">搜索</button>
	                    <button type="reset" class="btn btn-primary" style="margin-left: 40px;">重置</button>
	                    <button type="button" class="btn btn-primary" onclick="javascript:window.location.href='/project/showAdd'" style="margin-left: 40px;">添加</button>
                    </div><br>
                    <div class="form-group">
                        <label>项目类型</label>
                        <span th:each="ptd : ${projectTypeDictiontryList}">
                            <label style="font-weight: lighter;">
                                <input type="checkbox" name="projectType" th:value="${ptd.names}" th:text="${ptd.worth}" th:checked="${projectTypedArr != null ? #arrays.contains(projectTypedArr, ptd.names) : false}">
                            </label>
                        </span>
                    </div><br>
                    <div class="form-group">
                        <label>所属领域</label>
                        <span th:each="rfd : ${researchFieldDictiontryList}">
                            <label style="font-weight: lighter;">
	                            <input type="checkbox" name="researchField" th:value="${rfd.names}" th:text="${rfd.worth}" th:checked="${researchFieldArr != null ? #arrays.contains(researchFieldArr, rfd.names) : false}">
                            </label>
                        </span>
                    </div>
                    <div>
                        <span class="from-group">
                            <label>国内国外</label>
                            <label style="font-weight: lighter;">
                                <input type="radio" name="domesticOrForeign" id="optionsRadios1" value="0" th:checked="${project != null ? project.domesticOrForeign == 0 : false}"> 国内
                            </label>
                            <label style="font-weight: lighter;">
                                <input type="radio" name="domesticOrForeign" id="optionsRadios2" value="1" th:checked="${project != null ? project.domesticOrForeign == 1 : false}"> 国外
                            </label>
                        </span>
                        <span class="form-group form-area">
                            <select class="form-area" id="provinceId">
                                <option value="-1">--选择省--</option>
                                <option th:each="list:${provinceDictiontryList}" th:value="${list.names}" th:text="${list.worth}" th:selected="${list.names eq province}"></option>
                            </select>
                        </span>
                        <span class="form-group form-area">
                            <select class="form-area" id="cityId">
                                <option value="-1">--选择市--</option>
                                <option th:each="list:${cityDictiontryList}" th:value="${list.names}" th:text="${list.worth}" th:selected="${list.names eq city}"></option>
                            </select>
                        </span>
                        <span class="form-group form-area">
                            <select class="form-area" id="areaId">
                                <option value="-1">--选择区--</option>
                                <option th:each="list:${areaDictiontryList}" th:value="${list.names}" th:text="${list.worth}" th:selected="${list.names eq district}"></option>
                            </select>
                        </span>
                        <span class="form-group form-country">
                            <select class="form-area">
                                <option value="-1">--选择国家--</option>
                                <option th:each="list:${countryDictiontryList}" th:value="${list.pid}" th:text="${list.worth}" th:selected="${list.pid eq country}"></option>
                            </select>
                        </span>
                    </div>
                </form>
                <button id="dosubmit" class="btn btn-primary" title="作为持有人关联项目">关联</button>
                <div class="box">
                    <div class="box-body">
                        <table class="table table-bordered">
                            <tbody>
                                <tr>
                                	<th><input id="all" type="checkbox"></th>
                                    <th>项目id</th>
                                    <th>项目名称</th>
                                    <th>项目类型</th>
                                    <th>项目状态</th>
                                    <th>关联</th>
                                </tr>
                                <tr th:each="project : ${pageInfo.list}" th:with="isLinkedHolder=${#lists.contains(linkedProjectIdList, project.pid)}" th:class="${isLinkedHolder} ? butt-gray">
                                	<td>
                                		<input type="checkbox" class="matched" th:disabled="${isLinkedHolder}" th:value="'personId='+${param.personId}+'&projectId='+${project.pid}">
                                	</td>
                                    <td title="查看项目详情">
                                        <a th:href="@{'/project/showDetail?projectId='+${project.pid}}" th:text="'R' + ${project.projectNumber}">查看详情</a>
                                    </td>
                                    <td th:text="${#strings.length(project.projectName)} > 10 ? ${#strings.substring(project.projectName, 0, 10)}+'...' : ${project.projectName}" th:title="${project.projectName}">
                                    </td>
                                    <td th:text="${project.projectType}">类型</td>
                                    <td th:text="${project.projectStatusWorth}">状态</td>
                                    <td>
                                    	<a href="javascript:void(0);" th:class="${not isLinkedHolder} ? singleMatch">关联</a>
                                    </td>
                                </tr>
                            </tbody>
                        </table>
                        <p style="color: red;" th:text="${notHolderUpdate}"></p>
                        <p style="color: red;" th:text="${projectContactExists}"></p>
                        <p style="color: red;" th:text="${projectContactNotExists}"></p>
                        <div th:replace="page::html"></div>
                    </div>
                </div>
            </section>
        </div>
        <!-- Main Footer -->
        <div th:replace="footer::html"></div>
        <div class="control-sidebar-bg"></div>
    </div>
    <div th:replace="bottom::html"></div>
    <script type="text/javascript" th:inline="javascript">
        matchButt([[@{/project/linkHolder}]]);
        $("a.singleMatch").one("click", function() {
        	$(this).closest("tr").find(":checkbox").prop("checked", true);
        	matching([[@{/project/linkHolder}]]);
        });
    </script>
</body>

</html>